/* addr: tiny program to show possible representation of virtual address */

#include <sstream>
#include <iostream>

#include "paging_api.h"

using namespace std;

int main(int argc, char *argv[]) {
  if (argc != 2) {
    cout << "Usage: " << "addr <number>" << endl;
  }
  
  unsigned long long x;
  char c;
  if(argv[1][1] == 'x')
    istringstream(argv[1]) >> c >> c >> hex >> x;
  else
    istringstream(argv[1]) >> x;
  
  cout << I_PML4E_64(x) << '.' <<
	  I_PDPTE_64(x) << '.' <<
	  I_PDE_64(x)	<< '.' <<
	  I_PTE_64(x)	<< '.' <<
	  OFFSET_64_4KB(x) << endl;
	  
  cout << I_PML4E_64(x) << '.' <<
	  I_PDPTE_64(x) << '.' <<
	  I_PDE_64(x)	<< '.' <<
	  OFFSET_64_2MB(x) << endl;

  cout << I_PML4E_64(x) << '.' <<
	  I_PDPTE_64(x) << '.' <<
	  OFFSET_64_1GB(x) << endl;

  return 0;
}